package org.example.springcloud.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.example.springcloud.dao.AccountDao;
import org.example.springcloud.service.AccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @Description: 账户业务实现类
 * @Author: y
 * @CreateDate: 8/2/21 9:32 AM
 * @Version: 1.0
 */

@Service
@Slf4j
public class AccountServiceImpl implements AccountService {

    @Resource
    AccountDao accountDao;

    /**
     * 扣减账户余额
     */
    @Override
    public void decrease(Long userId, BigDecimal money) {

        log.info("------->account-service中扣减账户余额开始");
//        int x = 10 / 0;
//        try {
//            TimeUnit.SECONDS.sleep(20);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        accountDao.decrease(userId, money);
        log.info("------->account-service中扣减账户余额结束");
    }
}